#!/bin/bash
#complie, assemble, link the code
echo "start preprocessing"
gcc -E add.c -o add.i
gcc -E data.c -o data.i
gcc -E main.c -o main.i
echo "start compile"
gcc -S add.i
gcc -S data.i
gcc -S main.i
echo "start assemble"
gcc -c  add.s
gcc -c data.s
gcc -c main.s
as startup.s -o startup.o
echo "start link"
#ld -e main -o app -lc -I/lib64/ld-linux-x86-64.so.2 -T my.ld *.o
#ld -e main -o app --dynamic-linker -lc /lib64/ld-linux-x86-64.so.2 -T my.ld main.o add.o data.o
#ld main.o data.o add.o -e main -o app -lc -L/usr/lib/x86_64-linux-gnu/ --dynamic-linker /lib64/ld-linux-x86-64.so.2 -T my.ld 
#ld main.o data.o add.o -e main -o app -lc -L/usr/lib/x86_64-linux-gnu/ --dynamic-linker /lib64/ld-linux-x86-64.so.2 -T my.ld 
#ld -T my.ld main.o add.o data.o -o app1 /usr/lib/x86_64-linux-gnu/libc.so --dynamic-linker /lib64/ld-linux-x86-64.so.2
ld startup.o main.o data.o add.o -o app -lc -L/usr/lib/x86_64-linux-gnu/ --dynamic-linker /lib64/ld-linux-x86-64.so.2 -T my.ld -nostdlib
